home *** CD-ROM | disk | FTP | other *** search
/ Delphi 2.0 - Programmer's Utilities Power Pack / Delphi 2.0 Programmer's Utilities Power Pack.iso / s_to_z / tu / getdlg.pas < prev    next >
Encoding:
Pascal/Delphi Source File  |  1996-09-15  |  2.6 KB  |  102 lines

  1. unit Getdlg;
  2.  
  3. interface
  4.  
  5. uses WinTypes, WinProcs, Classes, Graphics, Forms, Controls, Buttons,
  6.   StdCtrls, ExtCtrls, SysUtils, BatchDlg, Dialogs, DBTables, DB;
  7.  
  8. type
  9.   TGetBatchDlg = class(TForm)
  10.     CancelBtn: TBitBtn;
  11.     HelpBtn: TBitBtn;
  12.     Bevel1: TBevel;
  13.     ButtonSelectBatch: TButton;
  14.     ButtonNewBatch: TButton;
  15.     OpenDialogSelectBatch: TOpenDialog;
  16.     SaveDialogNewBatch: TSaveDialog;
  17.     ButtonEdit: TButton;
  18.     procedure ButtonSelectBatchClick(Sender: TObject);
  19.     procedure ButtonNewBatchClick(Sender: TObject);
  20.     procedure ButtonEditClick(Sender: TObject);
  21.   private
  22.     { Private declarations }
  23.   public
  24.     { Public declarations }
  25.   end;
  26.  
  27. var
  28.   GetBatchDlg: TGetBatchDlg;
  29.  
  30. implementation
  31.  
  32. {$R *.DFM}
  33.  
  34. procedure TGetBatchDlg.ButtonSelectBatchClick(Sender: TObject);
  35. begin
  36.   if OpenDialogSelectBatch.Execute then
  37.   begin
  38.     FormBatchDef.TableBatch.Active := False;
  39.     FormBatchDef.TableBatch.DatabaseName :=
  40.       ExtractFilePath(OpenDialogSelectBatch.FileName);
  41.     FormBatchDef.TableBatch.TableName :=
  42.       ExtractFileName(OpenDialogSelectBatch.FileName);
  43.     modalResult := idYes;
  44.   end
  45.   else
  46.     modalResult := idCancel;
  47. end;
  48.  
  49. procedure TGetBatchDlg.ButtonNewBatchClick(Sender: TObject);
  50. begin
  51.   If SaveDialogNewBatch.Execute then
  52.   begin
  53.     with FormBatchDef.TableBatch do
  54.     begin
  55.       Active := False;
  56.       DatabaseName := ExtractFilePath(SaveDialogNewBatch.FileName);
  57.       TableName := ExtractFileName(SaveDialogNewBatch.FileName);
  58.       TableType := ttParadox;
  59.       Try
  60.         with FieldDefs do
  61.         begin
  62.           Clear;
  63.           Add('TableName',     ftString, 79, False);
  64.           Add('BackUpName',    ftString, 79, False);
  65.           Add('AltStructName', ftString, 79, False);
  66.           Add('KeyVTableName', ftString, 79, False);
  67.           Add('ProbTableName', ftString, 79, False);
  68.         end;
  69.         with IndexDefs do
  70.         begin
  71.           Clear;
  72.           Add('', 'TableName', [ixPrimary, ixUnique]);
  73.         end;
  74.         CreateTable;
  75.         modalResult := idOK;
  76.       except
  77.         modalResult := idCancel;
  78.         raise;
  79.       end;
  80.     end;
  81.   end
  82.   else
  83.     ModalResult := idCancel;
  84. end;
  85.  
  86. procedure TGetBatchDlg.ButtonEditClick(Sender: TObject);
  87. begin
  88.   if OpenDialogSelectBatch.Execute then
  89.   begin
  90.     FormBatchDef.TableBatch.Active := False;
  91.     FormBatchDef.TableBatch.DatabaseName :=
  92.       ExtractFilePath(OpenDialogSelectBatch.FileName);
  93.     FormBatchDef.TableBatch.TableName :=
  94.       ExtractFileName(OpenDialogSelectBatch.FileName);
  95.     modalResult := idOK;
  96.   end
  97.   else
  98.     modalResult := idCancel;
  99. end;
  100.  
  101. end.
  102.